package com.example.administrator.nl.base;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;

import com.example.administrator.nl.R;
import com.example.administrator.nl.util.ActivityManager;
import com.example.administrator.nl.util.ToastUtil;
import com.githang.statusbar.StatusBarCompat;

import butterknife.ButterKnife;

public abstract class BaseActivity extends AppCompatActivity {

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        int layoutVIew = getContentView();
        setContentView(layoutVIew);
        ButterKnife.bind(this);
        init();
        ToastUtil.init(this);
        ActivityManager.getInstance().addActivity(this);
    }
    public abstract int getContentView();

    public abstract void init();


    /**
     * @param color -1 默认主题颜色
     */
    public void setStatusBarCompat(int color) {
        if (color == -1) {
            StatusBarCompat.setStatusBarColor(this, ContextCompat.getColor(this, R.color.color_white_ffffff));
        } else {
            StatusBarCompat.setStatusBarColor(this, color);
        }
    }

}
